#!/bin/bash

echo "🔄 更新导入语句"
echo "================"

# 更新 react-native-fast-image 为 expo-image
echo "📝 更新 FastImage 导入..."
find . -name "*.tsx" -o -name "*.ts" | xargs grep -l "react-native-fast-image" 2>/dev/null | while read file; do
    echo "  更新文件: $file"
    sed -i '' 's/import FastImage from '\''react-native-fast-image'\''/import { Image as FastImage } from '\''expo-image'\''/g' "$file"
done

# 更新 react-native-mmkv 为 expo-secure-store
echo "📝 更新 MMKV 导入..."
find . -name "*.tsx" -o -name "*.ts" | xargs grep -l "react-native-mmkv" 2>/dev/null | while read file; do
    echo "  更新文件: $file"
    sed -i '' 's/import { MMKV } from '\''react-native-mmkv'\''/import * as SecureStore from '\''expo-secure-store'\''/g' "$file"
done

echo "✅ 导入更新完成！"
echo ""
echo "💡 注意：你可能需要手动更新一些使用这些库的代码"
echo "   - FastImage 的 API 与 expo-image 略有不同"
echo "   - MMKV 的 API 与 expo-secure-store 完全不同"
echo ""
echo "🔍 请检查以下文件并手动更新代码："
find . -name "*.tsx" -o -name "*.ts" | xargs grep -l "FastImage\|MMKV" 2>/dev/null 